BUI.use(['bui/form' ],
function(Form) {
	var form = new Form.Form({
		srcNode : '#searchForm'
	}).render();
	
	$("#btnSearch").bind('click', function() {
		showData();
	});
});

function showData(){
	var datas;
	var aQuery = $("#searchForm").serializeArray();		
	$.ajax({
		url : "queryRepeat",
		data : aQuery,
		type : "POST",
		dataType: "json",
		success : function(data){
			if(data!=null && data!=""){
				datas = [data.renew,data.repeatLend,data.totalLend,data.borrowerCount];
				var repeat_obj = $("#repeat_lend").find("tr:eq(1)");
				repeat_obj.find("td:eq(0)").html(percent((data.renew+data.repeatLend),data.borrowerCount));
				repeat_obj.find("td:eq(1)").html(fixedOne((data.renew+data.totalLend),data.borrowerCount));
				var repeat_obj = $("#renew_lend").find("tr:eq(1)");
				repeat_obj.find("td:eq(0)").html(percent(data.renew,data.borrowerCount));
				repeat_obj.find("td:eq(1)").html(fixedOne(data.renew,data.borrowerCount));
			}
		}
	});
}
function percent(a,b){
	if(b==null || b==0){
		return 0+"%";
	}
	return (a/b*100).toFixed(0)+"%";
}
function fixedOne(a,b){
	if(b==null || b==0){
		return 0;
	}
	return (a/b).toFixed(1);
}
